//
//  XLPlayExplainView.m
//  XiangLove
//
//  Created by Dgh Hv on 2018/10/19.
//  Copyright © 2018年 BAOMIHUA.COM. All rights reserved.
//

#import "XLPlayExplainView.h"

@implementation XLPlayExplainView

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    
    if (self) {
        
        //绘制界面显示
        [self initUI];
    }
    
    return self;
}

-(void)initUI
{
    self.backgroundColor = RGBA(0, 0, 0, 0.3);
    UIView * backView = [[UIView alloc]init];
    ViewRadius(backView, 5);
    backView.backgroundColor = KWhiteColor;
    [self addSubview:backView];
    
    [backView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(270, 358));
        make.center.equalTo(self);
    }];
    
    UIButton * closeButton = [[UIButton alloc]init];
    [closeButton setImage:IMAGE_NAMED(@"play_pop_icon_chacha_n") forState:UIControlStateNormal];
    kWeakSelf(self);
    [closeButton addTapBlock:^(UIButton *btn) {
        [weakself removeFromSuperview];
    }];
    [backView addSubview:closeButton];
    
    [closeButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(24, 24));
        make.top.equalTo(backView.mas_top).offset(5);
        make.right.equalTo(backView.mas_right).offset(-5);
    }];
    
    UILabel * title = [[UILabel alloc]init];
    title.text = @"玩法说明";
    title.font = [UIFont fontWithName:@"PingFangSC-Medium" size:18];
    title.textColor = RGB_HEX(0x030303);
    title.textAlignment = NSTextAlignmentCenter;
    [backView addSubview:title];
    [title mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(backView.mas_centerX);
        make.top.equalTo(backView.mas_top).offset(20);
    }];
    
    UILabel * contentLabel = [[UILabel alloc]init];
    NSString * content = @"1.点击抽奖按钮，消耗次数进行抽奖\n 2.转盘内的奖品分为：金豆、视频聊天卡\n 3.抽中的金豆会直接增加到用户的钱包中\n 4.抽中的视频聊天卡会增加到用户想爱钱包中的卡券里";
    NSMutableAttributedString * attributedString = [[NSMutableAttributedString alloc] initWithString:content];
    NSMutableParagraphStyle * paragraphStyle = [[NSMutableParagraphStyle alloc] init];
    [paragraphStyle setLineSpacing:14];
    [attributedString addAttribute:NSParagraphStyleAttributeName value:paragraphStyle range:NSMakeRange(0, [content length])];
    [contentLabel setAttributedText:attributedString];
//    contentLabel.text = @"";
    contentLabel.font = SYSTEMFONT(15);
    contentLabel.numberOfLines = 0;
    contentLabel.textColor = RGB_HEX(0x666666);
    [backView addSubview:contentLabel];
    
    [contentLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.equalTo(backView).insets(UIEdgeInsetsMake(56, 15, 64, 15));
    }];
    
    UIButton * understandButton = [[UIButton alloc]init];
    ViewRadius(understandButton, 18);
    understandButton.backgroundColor = RGB_HEX(0xFFDD02);
    [understandButton addTapBlock:^(UIButton *btn) {
        [weakself removeFromSuperview];
    }];
    [understandButton setTitle:@"已了解" forState:UIControlStateNormal];
    [understandButton setTitleColor:RGB_HEX(0x111111) forState:UIControlStateNormal];
    understandButton.titleLabel.font = SYSTEMFONT(16);
    [backView addSubview:understandButton];
    
    [understandButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(160, 36));
        make.centerX.mas_equalTo(backView.centerX);
        make.bottom.equalTo(backView.mas_bottom).offset(-19);
    }];
    
}

@end
